package com.neusoft.my12306.common.ex;

import com.neusoft.my12306.common.res.CommonResult;
import com.neusoft.my12306.common.res.IResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@CrossOrigin
@Slf4j
public class ExceptionsHandler {

    @ExceptionHandler({Exception.class})
    public CommonResult arithmeticException(Exception ex) {
        log.error("报错：{} ", ex.getMessage(), ex);
        CommonResult result = new CommonResult(IResult.INTERNALSERVER_ERROR, ex.getMessage(), null);
        return result;
    }
}
